﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Common.Utilities.Dispatcher;
using Workflows.Components.TextMining.Properties;

namespace Workflows.Components.TextMining.DocumentLabels
{
    ///<summary>
    ///</summary>
    [Serializable]
    public class DocumentLabelComponent:WorkflowComponentBase
    {
        /// <summary>
        /// 
        /// </summary>
        public DocumentLabelComponent():base()
        {
            this.ComponentActivityType = WorkflowActivityType.SimpleActivity;
            this.ComponentCategory = WorkflowComponentCategory.TextMining.ToString();
            this.ComponentName = "Doc Label";
            this.Description = "Label doc based on word freq proximity";
            this.ComponentIcon = Resources.apds_206;
            this.ComponentImage = Resources.vdt80pui_1053;

            this._Instruction=new DocumentLabelInstruction(
                this.ComponentID, Guid.Empty, string.Empty, string.Empty,
                25, 5, 10, string.Empty);
            this._Output = new DocumentLabelOutput(this.ComponentID, Guid.Empty, string.Empty, string.Empty);
        }

        #region Overrides of WorkflowComponentBase

        private DocumentLabelInstruction _Instruction;
        /// <summary>an object that encapsulate instruction settings.</summary>
        public override InstructionBase Instruction
        {
            get { return _Instruction; }
            set { _Instruction = (DocumentLabelInstruction) value; }
        }

        private DocumentLabelOutput _Output;
        /// <summary>an object to encapsulate output</summary>
        public override ResultBase Output
        {
            get { return _Output; }
            set { _Output = (DocumentLabelOutput) value; }
        }

        #endregion

        public override XmlNode Serialize(ref XmlDocument xDoc, ref XmlNode parentNode)
        {
            XmlNode xNode = base.Serialize(ref xDoc, ref parentNode);
            this.Instruction.Serialize(ref xDoc, ref xNode);
            return xNode;
        }

        public override WorkflowComponentBase Instantiate(XmlNode xNode)
        {
            DocumentLabelComponent component = (DocumentLabelComponent)base.Instantiate(xNode);
            component.Instruction = component.Instruction.Instantiate(xNode.SelectSingleNode("Instruction"));
            return component;
        }
    }
}
